import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/goods_detail_model.dart';

GoodsDetailModel $GoodsDetailModelFromJson(Map<String, dynamic> json) {
  final GoodsDetailModel goodsDetailModel = GoodsDetailModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    goodsDetailModel.id = id;
  }
  final int? shopId = jsonConvert.convert<int>(json['shop_id']);
  if (shopId != null) {
    goodsDetailModel.shopId = shopId;
  }
  final int? categoryId = jsonConvert.convert<int>(json['category_id']);
  if (categoryId != null) {
    goodsDetailModel.categoryId = categoryId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    goodsDetailModel.name = name;
  }
  final String? coverImage = jsonConvert.convert<String>(json['cover_image']);
  if (coverImage != null) {
    goodsDetailModel.coverImage = coverImage;
  }
  final String? imageUrls = jsonConvert.convert<String>(json['image_urls']);
  if (imageUrls != null) {
    goodsDetailModel.imageUrls = imageUrls;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    goodsDetailModel.description = description;
  }
  final String? descriptionBottom = jsonConvert.convert<String>(json['description_bottom']);
  if (descriptionBottom != null) {
    goodsDetailModel.descriptionBottom = descriptionBottom;
  }
  final double? price = jsonConvert.convert<double>(json['price']);
  if (price != null) {
    goodsDetailModel.price = price;
  }
  final double? pointsPrice = jsonConvert.convert<double>(json['points_price']);
  if (pointsPrice != null) {
    goodsDetailModel.pointsPrice = pointsPrice;
  }
  final double? marketPrice = jsonConvert.convert<double>(json['market_price']);
  if (marketPrice != null) {
    goodsDetailModel.marketPrice = marketPrice;
  }
  final int? stock = jsonConvert.convert<int>(json['stock']);
  if (stock != null) {
    goodsDetailModel.stock = stock;
  }
  final int? sales = jsonConvert.convert<int>(json['sales']);
  if (sales != null) {
    goodsDetailModel.sales = sales;
  }
  final String? tags = jsonConvert.convert<String>(json['tags']);
  if (tags != null) {
    goodsDetailModel.tags = tags;
  }
  final int? limit = jsonConvert.convert<int>(json['limit']);
  if (limit != null) {
    goodsDetailModel.limit = limit;
  }
  final double? rewardPoints = jsonConvert.convert<double>(json['reward_points']);
  if (rewardPoints != null) {
    goodsDetailModel.rewardPoints = rewardPoints;
  }
  final String? peer = jsonConvert.convert<String>(json['peer']);
  if (peer != null) {
    goodsDetailModel.peer = peer;
  }
  final double? freight = jsonConvert.convert<double>(json['freight']);
  if (freight != null) {
    goodsDetailModel.freight = freight;
  }
  final String? freightNotes = jsonConvert.convert<String>(json['freight_notes']);
  if (freightNotes != null) {
    goodsDetailModel.freightNotes = freightNotes;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    goodsDetailModel.content = content;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    goodsDetailModel.type = type;
  }
  final ShopInfoModel? shop = jsonConvert.convert<ShopInfoModel>(json['shop']);
  if (shop != null) {
    goodsDetailModel.shop = shop;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    goodsDetailModel.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
  if (updatedAt != null) {
    goodsDetailModel.updatedAt = updatedAt;
  }
  return goodsDetailModel;
}

Map<String, dynamic> $GoodsDetailModelToJson(GoodsDetailModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['shop_id'] = entity.shopId;
  data['category_id'] = entity.categoryId;
  data['name'] = entity.name;
  data['cover_image'] = entity.coverImage;
  data['image_urls'] = entity.imageUrls;
  data['description'] = entity.description;
  data['description_bottom'] = entity.descriptionBottom;
  data['price'] = entity.price;
  data['points_price'] = entity.pointsPrice;
  data['market_price'] = entity.marketPrice;
  data['stock'] = entity.stock;
  data['sales'] = entity.sales;
  data['tags'] = entity.tags;
  data['limit'] = entity.limit;
  data['reward_points'] = entity.rewardPoints;
  data['peer'] = entity.peer;
  data['freight'] = entity.freight;
  data['freight_notes'] = entity.freightNotes;
  data['content'] = entity.content;
  data['type'] = entity.type;
  data['shop'] = entity.shop?.toJson();
  data['created_at'] = entity.createdAt;
  data['updated_at'] = entity.updatedAt;
  return data;
}

extension GoodsDetailModelExtension on GoodsDetailModel {
  GoodsDetailModel copyWith({
    int? id,
    int? shopId,
    int? categoryId,
    String? name,
    String? coverImage,
    String? imageUrls,
    String? description,
    String? descriptionBottom,
    double? price,
    double? pointsPrice,
    double? marketPrice,
    int? stock,
    int? sales,
    String? tags,
    int? limit,
    double? rewardPoints,
    String? peer,
    double? freight,
    String? freightNotes,
    String? content,
    String? type,
    ShopInfoModel? shop,
    String? createdAt,
    String? updatedAt,
  }) {
    return GoodsDetailModel()
      ..id = id ?? this.id
      ..shopId = shopId ?? this.shopId
      ..categoryId = categoryId ?? this.categoryId
      ..name = name ?? this.name
      ..coverImage = coverImage ?? this.coverImage
      ..imageUrls = imageUrls ?? this.imageUrls
      ..description = description ?? this.description
      ..descriptionBottom = descriptionBottom ?? this.descriptionBottom
      ..price = price ?? this.price
      ..pointsPrice = pointsPrice ?? this.pointsPrice
      ..marketPrice = marketPrice ?? this.marketPrice
      ..stock = stock ?? this.stock
      ..sales = sales ?? this.sales
      ..tags = tags ?? this.tags
      ..limit = limit ?? this.limit
      ..rewardPoints = rewardPoints ?? this.rewardPoints
      ..peer = peer ?? this.peer
      ..freight = freight ?? this.freight
      ..freightNotes = freightNotes ?? this.freightNotes
      ..content = content ?? this.content
      ..type = type ?? this.type
      ..shop = shop ?? this.shop
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt;
  }
}

ShopInfoModel $ShopInfoModelFromJson(Map<String, dynamic> json) {
  final ShopInfoModel shopInfoModel = ShopInfoModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    shopInfoModel.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    shopInfoModel.name = name;
  }
  final String? logoUrl = jsonConvert.convert<String>(json['logo_url']);
  if (logoUrl != null) {
    shopInfoModel.logoUrl = logoUrl;
  }
  return shopInfoModel;
}

Map<String, dynamic> $ShopInfoModelToJson(ShopInfoModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['logo_url'] = entity.logoUrl;
  return data;
}

extension ShopInfoModelExtension on ShopInfoModel {
  ShopInfoModel copyWith({
    int? id,
    String? name,
    String? logoUrl,
  }) {
    return ShopInfoModel()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..logoUrl = logoUrl ?? this.logoUrl;
  }
}